<?php

/*

  Action	$6

  Reveal cards from your deck until you reveal 2 Treasure cards.
  Put those Treasure cards in your hand and discard the other revealed cards.

 */

class Adventurer extends Card implements iAction, iKingdom, iBasic {

    public function __construct() {
        parent::__construct("Adventurer", 6);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "Reveal cards from your deck until you reveal 2 Treasure cards. Put those Treasure cards in your hand and discard the other revealed cards.");
    }

    public function play(Game $game, $isRealCard) {

        $i = 0;
        $discarded_cards = array();
        $drawed_cards = array();
        while ($i < 2) {
            $card = $game->peekCardFromDrawDeck();

            if (!$card)
                break;
            if ($card instanceof iTreasure) {
                $i+=1;
                $game->drawCards(1);
                $drawed_cards[] = $card;
            } else {
                $card = $game->removeCardFromDrawDeck();
                $discarded_cards[] = $card;
            }
        }
        $game->discardTempDiscardCards($discarded_cards);
        ScreenDisplay::addScreenMessage($game, true, "put " . nicePrint($drawed_cards) . " in hand, and discard " . nicePrint($discarded_cards), "puts " . nicePrint($drawed_cards) . " in hand, and discards " . nicePrint($discarded_cards));

        $game->cardActionFinished();
        return true;
    }

}

?>